<!--suppress ALL -->
<include file="./Template/header.html" />
<link rel="stylesheet" type="text/css" href="/Template/css/common.css">
<link rel="stylesheet" type="text/css" href="/Template/css/confirmReceive.css">
<script type="text/javascript">
    window.onload = function(){

        //初始化页面配置
        document.title = "确认分奖形式";

        var btn = document.getElementById("confirm-btn");
        var price_btn = document.getElementById("price-btn");
        var body_bg = document.getElementById("body-bg");
        var alert_btn = document.getElementById("alert-frame");
        var address_frame = document.getElementById("address-frame");

        price_btn.onclick = function() {
            event.stopPropagation();
            address_frame.className = "address-frame active";
            body_bg.style.display = "block";
        }

        body_bg.onclick = function() {
            alert_btn.className = "alert-frame";
            address_frame.className = "address-frame";
            body_bg.style.display = "none";
        }

        var app = new Vue({
            el: '#container',
            data: {
                orderList: [],
            },
            methods: {
                index: indexPage,
                order: orderPage,
                rank: rankPage,
                center: centerPage,
				receiveCash: function(id) {
                    $.ajax({
                        url:"/wechat/order/receiveCash",
                        type:"post",
                        data:{
                            orderId:id,
                        },
                        dataType:"JSON",
                        beforeSend:function(){
                            $("#loadingToast").show();
                        },
                        complete:function(){
                            $('#loadingToast').hide();
                        },
                        success:function(data){
                            if(data.code != 200) {
                                alert(data.msg);
							} else {
                                event.stopPropagation();
                                alert_btn.className = "alert-frame active";
                                body_bg.style.display = "block";
							}
                        },
                    })
				},
				pay: function(id) {
                    if('{$priceDiff}' > 0) {
                        var name = $('input[name=name]').val();
                        var mobile = $('input[name=mobile]').val();
                        var address = $('input[name=address]').val();

                        window.location.href = "/wechat/product/pay/id/{$order.order_id}?name="+name+"&mobile="+mobile+"&address="+address;
                    } else {
                        var name = $('input[name=name]').val();
                        var mobile = $('input[name=mobile]').val();
                        var address = $('input[name=address]').val();
                        if (name == null || name == "") { 
                            alert("请填写姓名");  
                            return false;
                        }
                        if (mobile == null || mobile == "") { 
                            alert("请填写手机号");  
                            return false;
                        }
                        if (address == null || address == "") {
                            alert("请填写地址");  
                            return false;
                        }
                        $.ajax({
                            url:"/wechat/order/giftForFree",
                            type:"post",
                            data:{
                                orderId:'{$order.order_id}',
                                name: name,
                                mobile: mobile,
                                address: address
                            },
                            dataType:"JSON",
                            beforeSend:function(){
                                $("#loadingToast").show();
                            },
                            complete:function(){
                                $('#loadingToast').hide();
                            },
                            success:function(data){
                                if(data.code != 200) {
                                    alert(data.msg);
                                } else {
                                    alert('恭喜您兑换成功！请耐心等待我们工作人员与您联系。')
                                    window.location.href = "{$successUrl}";
                                }
                            },
                        })
                    }

				}
            }
        })
    }
</script>

<div class="confirm-receive" id="confirm-receive">
	<p class="the-win-info">恭喜您的幸运号码在本轮中奖！！<br/>
        您的团因您团胜，全团瓜分奖励！！<br/>
	请在下方选择领奖方式</p>
	<div class="first-choose">
        <p class="first-choose-way">方式一：全团瓜分奖金</p>
        <p class="all-money">全团共瓜分{$price}元，你获得了</p>
		<p class="get-money">{:round($groupMember['reward'] * C('DEFAULT_REWARD_FEE'),2)}</p>
		<div class="confirm-btn" id="confirm-btn" v-on:click="receiveCash('{$order.order_id}')">
			<p>确认领取</p>
		</div>
	</div>
	<div class="second-choose">
        <p class="first-choose-way">方式二：独享奖品</p>
		<div class="goods-img" style="background: url('{$order.image}')no-repeat center;background-size: cover;"></div>
		<div class="goods-title">{$order.product_name}</div>
		<div class="price-btn" id="price-btn">
			<p>补差给全团</p>
		</div>
        <div class="need-pay-money">补差金额{$priceDiff}元</div>
	</div>
    <img class="animate-png" src="/Template/images/animate.png">
</div>

<div class="alert-frame" id="alert-frame">
	<p class="color-66">已领取到{:round($groupMember['reward'] * C('DEFAULT_REWARD_FEE'),2)}</p>
	<div class="alert-btn" onclick="window.location.href='/Wechat/UserCenter/myWallet'">
		<p>查看余额</p>
	</div>
</div>

<div class="address-frame" id="address-frame">
    <p class="attention-info">我们会用快递将亲的宝贝寄出，请注意查收哦！虚拟电子物品，红包，充值卡等，请点击“去开团”微信公众号底部右下角“平台服务”中的“联系客服”按钮，与我们的客服人员联系领取。</p>
    <input type="text" name="name" placeholder="请填写收件人姓名">
    <input type="number" name="mobile" placeholder="请填写快递收件手机号（虚拟奖品也请填写真实手机号）">
    <input type="text" name="address" placeholder="请填写邮寄地址（虚拟奖品请任意填写）">
    <div class="submit-btn" v-on:click="pay('{$order.order_id}')">
        <p>提交</p>
    </div>  
</div>

<div class="body-bg" id="body-bg"></div>

<!-- loading toast -->
<div id="loadingToast" class="weui_loading_toast" style="display: none;">
	<div class="weui_mask_transparent"></div>
	<div class="weui_toast small">
		<div class="weui_loading">
			<div class="weui_loading_leaf weui_loading_leaf_0"></div>
			<div class="weui_loading_leaf weui_loading_leaf_1"></div>
			<div class="weui_loading_leaf weui_loading_leaf_2"></div>
			<div class="weui_loading_leaf weui_loading_leaf_3"></div>
			<div class="weui_loading_leaf weui_loading_leaf_4"></div>
			<div class="weui_loading_leaf weui_loading_leaf_5"></div>
			<div class="weui_loading_leaf weui_loading_leaf_6"></div>
			<div class="weui_loading_leaf weui_loading_leaf_7"></div>
			<div class="weui_loading_leaf weui_loading_leaf_8"></div>
			<div class="weui_loading_leaf weui_loading_leaf_9"></div>
			<div class="weui_loading_leaf weui_loading_leaf_10"></div>
			<div class="weui_loading_leaf weui_loading_leaf_11"></div>
		</div>
		<p class="weui_toast_content">正在处理</p>
	</div>
</div>
<!--end loading toast-->